<?php
namespace App\models;

use Illuminate\Database\Eloquent\Model;

class sever extends Model
{
    protected $table = 'server';
    public $timestamps = false;
    /**
     * @return mixed
     * 获取所有配置信息
     */
    public static function getConfig(){
        return static::find(1);
    }

    /**
     * 更新larval 文件配置
     */
    public static function UpdataConfig($config){
        $configFile = include(base_path()."../".'config/server.php');
        $configFile['tx']['appid'] = $config['sever_appid'];
        $configFile['tx']['bizid'] = $config['sever_bizid'];
        $configFile['tx']['key'] = $config['sever_appkey'];
        $c = file_put_contents(base_path()."../".'config/server.php',"<?php return ".var_export($configFile,true).';?>');
        if ($c) {
            return 1;
        }else{
            return 0;
        }
    }

}
